<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>ES6的解构赋值</title>
</head>
<body>
<script>
{
  //一个变量时
  let [x = true] = [];
  console.log(x); //输出结果：true
}

{
  //两个变量时
  let [x, y] = ['Hello']   //x赋值为：Hello，y没有赋值
  console.log(x + ',' + y); //输出结果：Hello,undefined
}


{
  //两个变量时
  let [x, y = 'vue'] = ['Hello']   //x赋值为：Hello，y采用默认值vue
  console.log(x + ',' + y); //输出结果：Hello,vue
}
	
{
  //y虽然被赋值为 undefined，但是y会采用默认值
  let [x, y = 'vue'] = ['Hello', undefined]; 
  console.log(x + ',' + y); //输出结果：Hello,vue
}

{
  let [x, y = 'vue'] = ['Hello', null];  //y被赋值为 null
  console.log(x + ',' + y); //输出结果：Hello,null
}
</script>
</body>
</html>